
#include <iostream>
#include "msg.h"
#include "SpecialLinkedList.h"

using namespace std;
using namespace msg;


void test_in_out_stream() //first menu item : first tester function for cin & cout members
{
	SpecialLinkedList L1;
	Step("Let's start with a SpecialLinkedList with value 1.",0);
	L1.add(1);
	Step("Now, we print it with cout << SpecialLinkedListObject;");
	cout << L1;
	Pause();
	Step("And we launch SpecialLinkedList's interactive element adder");
	Step("by running cin >> SpecialLinkedListObject;");
	Pause();
	cin >> L1;
	Step("Which gives for a new list:");
	cout << L1;
}


void test_assignment_function() //second menu item : second tester function for the overloading operator "="
{
    SpecialLinkedList L1;
    SpecialLinkedList L2;
	Step("Let's consider a SpecialLinkedList with value 1.",0);
	L1.add(1);
	Step("Now, we print it with cout << SpecialLinkedListObject;");
	cout << L1;
	Pause();
	Step("Now, let's do L2=L1, using the assignment operator \"=\"");
	L2 = L1;
	Step("To compare, let's show both of the two special linked lists L1 and L2 by running cin >> SpecialLinkedListObject;");
	cout << L2;
	cout << L1;
}


void test_equality_function() //third menu item : third tester function for the overloading operator "=="
{
    SpecialLinkedList L1;
    SpecialLinkedList L2;
	Step("Let's begin ! Please enter integer values when you will be asked for !");
	Step("By running cin >> SpecialLinkedListObject, enter your wanted value (size) for the list L1 ;");
	cin >> L1;
	Step("By running cin >> SpecialLinkedListObject, enter your wanted value (size) for the list L2 ;");
	cin >> L2;
	Step("Then, let's show L1 and L2 that should be ;");
	cout << L1;
	cout << L2;
	cout << "L1 & L2 are : "<< (L1==L2? "equal": "different")<<endl;
	Pause();
}


void test_the_plus_function() //fourth menu item : fourth tester function for the overloading operator "+" 
{
	SpecialLinkedList L1;
	SpecialLinkedList L2;
	SpecialLinkedList L3;
			
    Step("Let's begin ! Please enter integer values when you will be asked to !");
	Step("By running cin >> SpecialLinkedListObject, enter your wanted value (size) for the list L1 ;");
	cin >> L1;
	Step("By running cin >> SpecialLinkedListObject, enter your wanted value (size) for the list L2 ;");
	cin >> L2;
	Step("Then, let's print them with cout << SpecialLinkedListObject;");
	cout << L1;
	cout << L2;
	Step("Finally, let's create a third Special Linked List named L3 which will contain both of L1 and L2 --> L3 = L1+L2");
	L3 = L1+L2;
	Step("We want to see : ");
	cout << L3;
}


void test_the_minus_function()  //fifth menu item : fifth tester function for the overloading operator "-" 
{
	SpecialLinkedList L1;
	SpecialLinkedList L2;
	SpecialLinkedList L3;
			
    Step("Let's begin by the regular case! {where L1.size() > L2.size()} ");
	L1.add(4);
	L1.add(8);
	L1.add(6);
	L2.add(6);
	Step("Then, let's print them with cout << SpecialLinkedListObject;");
	cout << L1;
	cout << L2;
	Step("Finally, let's create a third Special Linked List named L3 which will contain both of L1 and L2 --> L3 = L1-L2");
	L3 = L1-L2;
	Step("We sould obtain two nodes : 4 & 8, let's ckeck : ");
	cout << L3;
	
	Step("Let's resume considering the case where there is L1.size() < L2.size() "  );
	L1.add(4);
	L2.add(6);
	L2.add(8);
	Step("Then, let's print them with cout << SpecialLinkedListObject;");
	cout << L1;
	cout << L2;
	Step("Finally, let's create a third Special Linked List named L3 which will contain both of L1 and L2 --> L3 = L1-L2");
	L3 = L1-L2;
	Step("Now there should be an error ");
	cout << L3;
	
}


void test_Index_function() //sixth menu item : sixth tester function for the overloading operator "[]"
{
 	SpecialLinkedList L1;
	L1.add(1);
	L1.add(6);
	L1.add(18);
	cout << L1[-1] <<endl;
	cout << L1[0] <<endl;
	cout << L1[20] <<endl;
	
}


int main()
{
	MenuItem m1(test_in_out_stream,"operator<<(ostream,...) and operator>>(istream,...)");
	MenuItem m2(test_assignment_function,"operator=");
	MenuItem m3(test_equality_function,"operator==");
	MenuItem m4(test_the_plus_function,"operator+");
	MenuItem m5(test_the_minus_function,"operator-");
	MenuItem m6(test_Index_function,"operator[]");

	Menu M("Testing of the Special_Linked_List class");
	
	M.add(m1);
	M.add(m2);
	M.add(m3);
	M.add(m4);
	M.add(m5);
    M.add(m6);

	M.run();
	
	return 0;
}

